<script language="javascript" type="text/javascript" src="../../public/jquery.min.js"></script>
<style>
  *{
    font-size: 12px;
  }
  .biaoti{
    font-size: 14px;
    background:gainsboro;
    padding: 5px;
    font-weight: 900;
  }
</style>
<section style="width: 100%">
  <form >
    <fieldset>
      <legend><span style="font-size: 16px;font-weight: 900">通用维度页面 匹配到(<%= alldata.length %>)条数据<span id="modelname" style="display: none;"><%= model %></span></span></legend>
      <div id="alldatastr">
        <%= JSON.stringify(alldata[0])%>
      </div>
    </fieldset>
  </form>
</section>
<section>
  <form >
    <fieldset>
      <legend><span style="font-size: 16px;font-weight: 900">涉及到的关系</span></legend>
      <div id="hihi">

      </div>

    </fieldset>
  </form>
</section>
<section>
  <form >
    <fieldset>
      <legend><span style="font-size: 16px;font-weight: 900">Maybe</span></legend>
      <div style="display: none">
        这个维度下的所有所有数据的id:<br/>
        <% if (alldata[0]["es-Entitys"].length) { %>
        <ul>
          <% alldata[0]["es-Entitys"].forEach(function(ese){ %>
          <li class="ids" value="<%= ese["es-id"] %>" style="float: left;margin-right: 5px"><%= ese["es-id"] %></li>
          <% }) %>
        </ul>
        <% } %>

      </div>
      <div id="other">

      </div>
    </fieldset>
  </form>
  <script>
    var mb={
      wd_DZ:["dz-ssaj-FADXZ","dz-szaj-FADXZ","dz-bjr-SJJZDZXZ","dz-gnryzsjl-ADDRESS","dz-shr-SJJZDZXZ","dz-zr-HJDZXZ"],
      wd_XM:["xm-xxr-XM","xm-hjxx-XM","xm-bjr-XM","xm-ksszyryjbxx-XM","xm-ksszyryjbxx-BMCH","xm-shr-XM","xm-zr-XM","xm-gnryzsjl-XM"],
      wd_HH:[["hh-hjxx-HH"]],
      wd_FWCS:["fwcs-xxr-SJJZDZXZ","fwcs-hjxx-FWCS","fwcs-bjr-HJDZXZ","fwcs-bjr-FWCS","fwcs-ksszyryjbxx-FWCS"],
      wd_AJSLWH:["ajslwh-xsaj-SLWH","ajslwh-xzaj-SLWH"],
      wd_AJMC:["ajmc-xsaj-AJMC","ajmc-xzaj-AJMC"],
      wd_AJBH:["ajbh-xzaj-AJBH","ajbh-xsaj-AJBH","ajbh-xxr-AJBH","ajbh-shr-AJBH","ajbh-bjr-AJBH","ajbh-zr-AJBH"],
      wd_DHHM:["dhhm-hjxx-LXFS","dhhm-bjr-LXFS","dhhm-shr-LXFS","dhhm-zr-LXFS"],
      wd_SFZ:["sfz-xxr-SFZH","sfz-bjr-SFZH","sfz-zr-SFZH","sfz-shr-SFZH","sfz-ksszyryjbxx-SFZH","sfzh-hjxx-SFZH","sfzh-gnryzsjl-CERTVALUE"],
      wd_JDMC:["jdmc-gnryzsjl-HOTELNAME"]
    };
    var alldatastr=$("#alldatastr").html();
    var cc=mb[$("#modelname").html()];
    $.each(cc,function (i,obj) {
      $("#hihi").append("<span>"+mcpd(obj)+"("+JSON.parse(alldatastr)[obj].length+")</span> ");
    })
    for(var p in mb){//遍历json对象的每个key/value对,p为key
      $("#other").append("<div id='"+p+"'><span class='biaoti'>关联到的"+wdmcpd(p)+"</span><p class='pps'></p></div>")
    }
    for(var pp in mb){//遍历json对象的每个key/value对,p为key
      $.each($(".ids"),function (i,value) {
        var thvalue = $(value).attr("value");
        var ppp=pp;
        $.ajax({
          url: "/api/" + (pp=="wd_FWCS"?"wd_FWCs":pp+"s?access_token=FQTyYwQXDVjnyo3NXluUDWZccQfsJfBANrnl7Fssx20RmhqCkWbx8XXjr4TE35Ff"),
          data: {filter: {"where": {"es-Entitys.es-id.keyword": thvalue}}},
          success: function (data) {
            if (data.length > 0) {
              $.each(data, function (ii, vv) {
               if($("#"+vv.id).length>0) return;
                $("#" + ppp +" .pps").append("<span id='"+vv.id+"'><a href='/allmb?wdid="+vv.id+"&model="+ppp+"'>" + vv.id + "</a></span> ")
              })
            }
          }
        });
      });
    }
    function mcpd(ob) {
      if(ob.indexOf("xxr")>=0) return "嫌疑人库";
      if(ob.indexOf("xsaj")>=0) return "刑事案件";
      if(ob.indexOf("xzaj")>=0) return "行政案件";
      if(ob.indexOf("ssaj")>=0) return "刑事案件";
      if(ob.indexOf("szaj")>=0) return "行政案件";
      if(ob.indexOf("bjr")>=0) return "报警人";
      if(ob.indexOf("gnryzsjl")>=0) return "国内人员住宿记录";
      if(ob.indexOf("shr")>=0) return "被害人";
      if(ob.indexOf("zr")>=0) return "证人";
      if(ob.indexOf("ksszyryjbxx")>=0) return "看守所在押人员";
      if(ob.indexOf("hh-hjxx-HH")>=0) return "常驻人口";
      if(ob.indexOf("hjxx")>=0) return "常驻人口";

      return ob;
    }
    function wdmcpd(ob) {
      if(ob.indexOf("DZ")>=0) return "地址";
      if(ob.indexOf("XM")>=0) return "姓名";
      if(ob.indexOf("SFZ")>=0) return "身份证";
      if(ob.indexOf("wd_HH")>=0) return "户号";
      if(ob.indexOf("JDMC")>=0) return "酒店名称";
      if(ob.indexOf("DHHM")>=0) return "电话号码";
      if(ob.indexOf("AJMC")>=0) return "案件名称";
      if(ob.indexOf("AJBM")>=0) return "案件编号";
      if(ob.indexOf("AJSLWH")>=0) return "案件受理文号";
      if(ob.indexOf("CPH")>=0) return "车牌号";
      if(ob.indexOf("WBMC")>=0) return "网吧名称";
      if(ob.indexOf("FWCS")>=0) return "服务处所";
      if(ob.indexOf("HYDJZH")>=0) return "婚姻登记证号";
      if(ob.indexOf("AJBH")>=0) return "案件编号";
    }
  </script>
</section>
